package Builder;

import java.util.Comparator;

public class Computer {
    private  String CPU;
    private  int memory;      // 内存大小，单位GB
    private  int storage;     // 存储大小，单位GB
    private  String GPU;

    //设置成私有为了只能由Builder来实现构造初始化
    private Computer(String CPU, int memory, int storage, String GPU) {
        this.CPU = CPU;
        this.memory = memory;
        this.storage = storage;
        this.GPU = GPU;
    }

    @Override
    public String toString() {
        return "Computer{" +
                "CPU='" + CPU + '\'' +
                ", memory=" + memory +
                ", storage=" + storage +
                ", GPU='" + GPU + '\'' +
                '}';
    }

    //生成构造

    public String getCPU() {
        return CPU;
    }

    public int getMemory() {
        return memory;
    }

    public int getStorage() {
        return storage;
    }

    public String getGPU() {
        return GPU;
    }

    public static  class ComputerBuilder{
        private  String CPU;
        private  int memory;      // 内存大小，单位GB
        private  int storage;     // 存储大小，单位GB
        private  String GPU;

        public ComputerBuilder setCPU(String CPU){
            this.CPU = CPU;
            return this;
        }
        public ComputerBuilder setmemory(int memory){
            this.memory = memory;
            return this;
        }
        public ComputerBuilder setstorage(int storage){
            this.storage = storage;
            return this;
        }
        public ComputerBuilder setGPU(String GPU){
            this.GPU = GPU;
            return this;
        }

        public Computer builder(){
            return new Computer(CPU,memory,storage,GPU);
        }
    }
}
